package com.example.demo.controller;

import com.example.demo.model.Gmmana;
import com.example.demo.service.IGmmanaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 张少婷
 */

@Api(tags = "劳保采购信息")
@RestController
@RequestMapping("/swagger10")
public class GmmanaController {
    @Autowired
    private IGmmanaService gmmanaService;
    @CrossOrigin
    @ApiOperation(value="添加采购信息")
    @PostMapping("/insertGmmana")
    public int insertGmmana(@RequestBody Gmmana gmmana){
        System.out.println("进入添加购买信息接口" );
        return gmmanaService.insertGmmana(gmmana);
    }

    @PostMapping("/getAllGmmana")
    public List<Gmmana> getAllGmmana(@RequestBody Gmmana gmmana)
    {
        System.out.println("进入查询方法");
        List<Gmmana> listGmmana=gmmanaService.getAllGmmana(gmmana);
        return listGmmana;
    }
    @PostMapping("/editGmmana")
    public int EditGmmana(@RequestBody Gmmana gmmana){
        System.out.println("添加修改方法");
        return gmmanaService.updateGmmana(gmmana);
    }
    @GetMapping("/delGmmana")
    public int Delete(int lbid){
        System.out.println("进入删除方法");
        int returnValues=0;
        if(lbid!=0){
            Gmmana gmmana=new Gmmana();
            gmmana.setLbid(lbid);
            returnValues=gmmanaService.deleteGmmana(gmmana);
        }
        return returnValues;
    }

    @GetMapping("/getOneGmmana")
    public Gmmana getGmmana(int lbid){
        Gmmana gmmana=new Gmmana();
        System.out.println("进入单条查询方法");
        if(lbid!=0){
            Gmmana gmmana1=new Gmmana();
            gmmana1.setLbid(lbid);
            gmmana=gmmanaService.getGmmana(gmmana1);
            System.out.println("返回的数据集合为:"+gmmana.getLbid());
        }
        return gmmana;
    }
}
